﻿@using NewtouchHIS.Lib.Framework.Operator;
 
@{
    var opr = OperatorProvider.GetCurrent();
}
<div id="content-wrapper">
    <div class="content-tabs">
        <button class="roll-nav roll-left tabLeft">
            <i class="fa fa-angle-double-left"></i>
        </button>
        <nav class="page-tabs menuTabs">
            <div class="page-tabs-content" style="margin-left: 0px;">
                @if (!string.IsNullOrWhiteSpace(opr?.OrganizeId))
                {
                    <a href="javascript:;" class="menuTab active" data-id="/Home/WorkSpace">首页</a>
                }
            </div>
        </nav>
        <button class="roll-nav roll-right tabRight">
            <i class="fa fa-angle-double-right" style="margin-left: 3px;"></i>
        </button>
        <div class="btn-group roll-nav roll-right">
            <button class="dropdown tabClose" data-toggle="dropdown">
                页签操作<i class="fa fa-caret-down" style="padding-left: 3px;"></i>
            </button>
            <ul class="dropdown-menu dropdown-menu-right">
                <li><a class="tabReload" href="javascript:void(0);">刷新当前</a></li>
                <li><a class="tabCloseCurrent" href="javascript:void(0);">关闭当前</a></li>
                <li><a class="tabCloseAll" href="javascript:void(0);">全部关闭</a></li>
                <li><a class="tabCloseOther" href="javascript:void(0);">除此之外全部关闭</a></li>
                <li><a class="tabSaveMune" href="javascript:void(0);"><i class="fa fa-star icon-theme-highlight"></i>收藏当前页</a></li>
            </ul>
        </div>
        <button class="roll-nav roll-right fullscreen"><i class="fa fa-arrows-alt"></i></button>
    </div>
    <div class="content-iframe" style="background-color:#f1f4f6; overflow: hidden;">
        <div class="mainContent" id="content-main" style="margin: 10px; margin-bottom: 0px; padding: 0;">
            @if (!string.IsNullOrWhiteSpace(opr.OrganizeId))
            {
                <iframe class="Newtouch_iframe" id="iframeaaaaaaaaaaaaaaaaa" name="iframeaaaaaaaaaaaaaaaaa" width="100%" height="100%" src="" frameborder="0" data-id="/Home/WorkSpace"></iframe>
            }
        </div>
    </div>
</div>

    <script>
    $('.tabSaveMune').on('click', function () {
        var title=$('.page-tabs-content').find('.active')[0].innerText;
        var currentUrl = $('.page-tabs-content').find('.active').attr('data-id');
        var theRequest = new Object();
        theRequest["MenuName"] = title;
        if (currentUrl.indexOf("?") != -1) {
            const urlObj = new URL(currentUrl);
            var dd = {
                protocol: urlObj.protocol,
                host: urlObj.host,
                path: urlObj.pathname,
                query: urlObj.searchParams.toString(),
                fragment: urlObj.hash
            }
            var str = urlObj.searchParams.toString();
            theRequest["host"] = urlObj.origin+"/";
            
            strs = str.split("&");
            for (var i = 0; i < strs.length; i++) {
                theRequest[strs[i].split("=")[0]] = unescape(strs[i].split("=")[1]);
            }
        }else
        {
            theRequest["returnUrl"] = currentUrl;
        }
        $.ajax({
            url: "/Home/SaveShortcutMenu",
            data: { "request": theRequest },  
            type: "post",
            dataType: "json",
            success: function (data) {
                if (data.state == "success") {
                    $.modalAlert(data.message, 'success');
                }
                else
                {
                    $.modalAlert(data.message, 'warning');
                }
            },
            error: function (request, error, ex) {
                $.modalAlert("服务不可访问：[" + ex + "]", 'error');
            }
        });
    });

    </script>